<?php
/**
 *  邮箱验证类
 */

namespace app\api\service;
use app\facade\Basic;
use app\facade\Mail;
use think\facade\Cache;

class MailCheck
{
    /**
     *  验证
    */
    public static function check($param)
    {
       return Cache::get($param['email']);
    }

    /**
     *  创建验证码
    */
    public static function create($param)
    {
//        $result = MailService::sendMail($param['to'],$param['subject'],$param['content']);
        $result = Mail::send('code',['email'=>$param['to'],'code'=>$param['code']]);
        if ( $result ){
            Cache::set($param['to'],$param['code'], 600);
            return Basic::data(0,'common.success');
        } else {
            return Basic::data(1,'common.error');
        }
    }

}